﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Utils.MathUtilitys;

namespace Utils.Drawing
{
    public class RectSprite : Sprite
    {
        FRect rect;

        public FRect Rect { get { return rect; } set { rect = value; } }

        public RectSprite(Texture2D texture) : base(texture) 
        {
            origin = ORIGIN_TOP_LEFT;
        }

        public override void Draw(float dTime, SpriteRenderer spriteRenderer)
        {
            Color col;
            if (blendState == BlendState.AlphaBlend || blendState == SpriteRenderer.AdditivePremultiplied)
            {
                col = color * alpha;
            }
            else
            {
                col = color;
                col.A = (byte)(col.A * alpha);
            }

            spriteRenderer.Draw(
                texture, rect, source, col, rotation,
                new Vector2(origin.X * texture.Width, origin.Y * texture.Height), 
                blendState, effect, spriteEffects);
        }
    }
}
